package com.example.springbooksystem.model;

import com.example.springbooksystem.enums.ResultStatusEnum;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-01-25
 * @time: 18:07:11
 */
@Data
public class ResponseData {
    private Object data;
    // private Integer code;
    private ResultStatusEnum resultStatusEnum;
    private String errMessage;

    /*
     * @description:成功的时候
     * @author: zxj
     * @date: 2024/1/25 20:14
     * @param:
     * @return:
     **/
    public static ResponseData success(Object data) {
        ResponseData responseData = new ResponseData();
        responseData.setData(data);
        responseData.setResultStatusEnum(ResultStatusEnum.SUCCESS);
        responseData.setErrMessage("");
        return responseData;
    }

    /*
     * @description: 未登录
     * @author: zxj
     * @date: 2024/1/25 20:16
     * @param:
     * @return:
     **/
    public static ResponseData unLogin(Object data) {
        ResponseData responseData = new ResponseData();
        responseData.setData(data);
        responseData.setResultStatusEnum(ResultStatusEnum.UN_LOGIN);
        responseData.setErrMessage("用户未登录");
        return responseData;
    }

    /*
     * @description: 失败了
     * @author: zxj
     * @date: 2024/1/25 20:18
     * @param:
     * @return:
     **/
    public static ResponseData fatal(String errMessage) {
        ResponseData responseData = new ResponseData();
        responseData.setData(null);
        responseData.setResultStatusEnum(ResultStatusEnum.FATAL);
        responseData.setErrMessage(errMessage);
        return responseData;
    }
}
